package lzzy.net.controller;

import lzzy.net.entity.Comment;
import lzzy.net.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/comment/{id}")
    public Comment findComment(@PathVariable("id") Integer id){
        return commentService.findById(id);
    }
    @GetMapping("/comment/{id}/{content}")
    public Comment updateComment(@PathVariable("id") Integer id,
                                 @PathVariable("content") String content){
        return commentService.updateComment(id, content);
    }
    @GetMapping("/comment/delete/{id}")
    public void deleteComment(@PathVariable("id") Integer id) {
        commentService.deleteCommentById(id);
    }
}
